----------------------------
-- Simplistic Street
-- by Jammie Dodger
--
-- Project Started - October 20, 2009
-- Completion -None
----------------------------

local EMeta = FindMetaTable( "Entity" )

local DoorTable = { "func_door", "func_door_rotating", "prop_door_rotating" }

local CopOnlyDoors = {

	Vector(-1581, 31, -141.71899414063),
	Vector(-1850, 271, -142),
	Vector(-1950, 271, -142),
	Vector(-2146, 271, -142),
	Vector(-2246, 271, -142),
	Vector(-1454, 139, -142),
	Vector(-1569, 139, -142),
	Vector(-1581, 31, -141),
	Vector(-1569, 355, -142),
	Vector(-1697, 355, -142),
	Vector(-2327, 31, -142),
	Vector(-2281, -135, -142),
	Vector(-2087, -29, 38),
	Vector(-1727, 139, 217),
	Vector(-2113, -118, 217)
	
}

local UnOwnableDoors = {

	Vector(1486, -1084.5, -100.99894714355),
	Vector(1486, -1084.5, -132),
	Vector(1434, -1084.5, -132),
	Vector(1434, -1084.5, -101),
	Vector(-1297, 1637, -394),
	Vector(-1297, 1704, -554),
	Vector(-1005, 1217, -554),
	Vector(-1054, -1165, -142),
	Vector(-1054, -1071, -142),
	Vector(-718, -1355, -142),
	Vector(-718, -1355, -6),
	Vector(-718, -1355, 122),
	Vector(-718, -1355, 250),
	Vector(-810, -1305, 378),
	Vector(-1896, -146, -112),
	Vector(-1896, -146, -176),
	Vector(-1896, -146, -372),
	Vector(-1853, -409, -402),
	Vector(-1767, -299, -401),
	Vector(-721, -1468, 257.375),
	Vector(-813, -1459, 252),
	Vector(-1353, -1267, -629),
	Vector(-1919, -1267, -629),
	Vector(-1919, -1731, -629),
	Vector(-1615, -2259, -898),
	Vector(-2601, -2189, -442),	
	
}

function EMeta:IsDoor()
	local Class = self:GetClass()
	
	for k, v in pairs( DoorTable ) do
		if ( Class == v ) then
			return true
		end
	end
	
	return false
end

function EMeta:IsUnownable()

	if self:GetNWBool("Elevator") == true then
		return true
	end

	for k, v in pairs( UnOwnableDoors ) do
		if v == self:GetPos() then
			return true
		end
	end
	
	return false
end

if SERVER then

function EMeta:Locked()
	return self.IsLocked
end

end

function EMeta:IsCopOnly()

	for k, v in pairs( CopOnlyDoors ) do
		if v == self:GetPos() then
			return true
		end
	end
	
	return false
end

local PMeta = FindMetaTable("Player")

function PMeta:EyeTrace( dis )
	local tr = {}
	tr.start = self:GetShootPos()
	tr.endpos = tr.start + ( self:GetCursorAimVector() * dis )
	tr.filter = self
	tr = util.TraceLine( tr )
	return tr
end